import BuffUtil from '@/BuffUtil';
import TalentBase from 'code/Scripts/Abilities/base/TalentBase';
const desc = `被你直接伤害过的敌人在5秒内受到的伤害提升${ColorSafe}5%|r，持续${ColorSafe}5|r秒。|n觉醒效果：持续时间延长到${ColorSafe}10|r秒`;
const art = 'assets\\icon\\Spell_Holy_SenseUndead.blp';
const name = '易伤诅咒';
const config: TalentConfigModel = {
    id: 'talent_t_TalentVulnerabilityCurse',
    name,
    desc,
    art,
    buffType: {
        id: 'buff_t_TalentVulnerabilityCurse',
        art,
        name,
        ubertip: desc,
    },
    buffTypePlus: {
        id: 'buff_t_TalentVulnerabilityCurse_plus',
        art,
        name: '易伤诅咒[觉醒]',
        ubertip: '被你直接伤害过的敌人在5秒内受到的伤害提升${ColorSafe}5%|r，持续${ColorSafe}10|r秒',
    },
};

const effectBuffType: AppBuffType = {
    id: 'buff_t_TalentVulnerabilityCurse_effect',
    art,
    name,
    ubertip: '受到的伤害增强',
    dur: 5,
    stackCountMax: -1,
    stackDurMode: true,
    isDebuff: true,
    attribute: {
        物理伤害减免: -0.05,
        法术伤害减免: -0.05,
    },
    targetAttach: 'origin',
    targetArt: 'Abilities\\Spells\\Other\\Parasite\\ParasiteTarget.mdl',
};

const effectBuffTypePlus: AppBuffType = { ...effectBuffType, id: 'buff_t_TalentVulnerabilityCursePlus_effect', dur: 10 };

export default class TalentVulnerabilityCurse extends TalentBase {
    static instance: TalentVulnerabilityCurse;
    constructor(p?: TalentConfigModel) {
        super(p);
        TalentVulnerabilityCurse.instance = this;
        this.setTalentConfig(config);
        this.init();
        EventManager.onBeforTakeDamage(this.damageEffect);
    }
    damageEffect(d: DamageEventData) {
        if (d.isDot) return;
        let _this = TalentVulnerabilityCurse.instance;
        let { unEffect, plus } = _this.talentUnEffect(d.source);
        if (unEffect) return;
        let id = plus ? effectBuffTypePlus.id : effectBuffType.id;
        BuffUtil.addBuff(d.target, id, d.source);
    }
    init() {
        BuffUtil.registerBuffType(effectBuffType);
        BuffUtil.registerBuffType(effectBuffTypePlus);
    }
}
